package com.jianying.mapper;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.jianying.base.BaseMapper;
import com.jianying.dataSource.TargetDataSource;
import com.jianying.domain.Customer;

@Repository("customerMapper")
public class CustomerMapper extends BaseMapper {
	
	private static final String NAME_SPACE = "com.jianying.mapper.CustomerMapper.";
	
	@TargetDataSource(name="ds1")
	public void insert(Customer customer){
		getSqlSessionTemplate().insert(NAME_SPACE + "insert", customer);
	}
	
	@TargetDataSource(name="ds1")
	public Customer byPhone(String phone, Integer tenantId){
		Map<String, Object> map = new HashMap<>();
		map.put("phone", phone);
		map.put("tenantId", tenantId);
		return getSqlSessionTemplate().selectOne(NAME_SPACE + "byPhone", map);
	}
	
}
